'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:ContractZjcontractCtrl
 * @description
 * # ContractZjcontractCtrl
 * Controller of the jgappApp
 */
angular.module('jgappApp')
    .controller('ContractZjcontractCtrl', function ($scope, $rootScope, openApi, Util, $routeParams, FormSubmit) {
        var id = $scope.process_id = $routeParams.id
        $scope.param = {};
        $scope.payWayList = [{
            key: "一次性付清",
            value: "一次性付清"
        }, {
            key: "每年支付",
            value: "每年支付"
        }, {
            key: "每月支付",
            value: "每月支付"
        }, {
            key: "其他方式",
            value: "其他方式"
        }, {
            key: "预付款",
            value: "预付款"
        }];
        $scope.showMajorTypeObj = function () {
            var param = {};
            param.type = "证件合同类别";
            Util.getKeyValue(param, function (data) {
                $scope.majorTypeList = data.data
            })
        };
        $scope.submit = function (operationId) {
            // 底部类型end
            var options = {};
            // 流程id
            options.id = id;
            // 根据operationId判断是草稿还是提交
            options.operationId = operationId;
            options.urlParam = openApi.agreementApply;
            options.param = angular.copy($scope.param, {});
            FormSubmit.submit(options,$scope);
        };
        $scope.validate = function () {
            if (!$scope.param.major) {
                Util.Toast("请选择证件类型");
                return;
            }
            if (!$scope.param.constructor_) {
                Util.Toast("请填写证件姓名");
                return;
            }
            if (!$scope.param.specialty) {
                Util.Toast("请填写专业");
                return;
            }
            if (!$scope.param.cost) {
                Util.Toast("请填写证件费用");
                return;
            }
            if (!$scope.param.payWay) {
                Util.Toast("请选择付款方式");
                return;
            }
            if (!$scope.validation.passvalidation) {
                Util.Toast($scope.validation.tip);
                return;
            }
            return true;
        }
        var init = function () {
            // 获取回显的详细信息
            Util.getDetailData(id, function (data) {
                $scope.param = data;
            });
            $scope.showMajorTypeObj();
        };
        // 初始化
        init();

    });
